package application.services;

import application.model.PhaseCompositionsModel;
import application.translators.Translator;
import application.translators.impl.PhaseCompositionsTranslator;
import dao.PhaseCompositionDao;
import mappings.PhaseComposition;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Path("phaseCompositions")
public class PhaseCompositionsService
{
    PhaseCompositionDao phaseCompositionDao = new PhaseCompositionDao();
    Translator<List<PhaseComposition>, PhaseCompositionsModel> translator = new PhaseCompositionsTranslator();

    @Path("getForMaterial/{materialId}")
    @GET
    @Produces(MediaType.APPLICATION_XML)
    public PhaseCompositionsModel getAllPhaseCompositionsForMaterial(@PathParam("materialId") int materilId)
    {
        return translator.translate(phaseCompositionDao.getPhaseCompositionsForMaterial(materilId));
    }
}
